home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE07 / HTMLVIEW / HTMLVIEW.ZIP / INSTALL.ZIP / HTMLVIEW.INT < prev    next >
Encoding:
Text File  |  1995-12-22  |  5.9 KB  |  150 lines

  1. {*********************************************************}
  2. {*                     HTMLVIEW.PAS                      *}
  3. {*                 Copyright (c) 1995 by                 *}
  4. {*                   L. David Baldwin                    *}
  5. {*                 All rights reserved.                  *}
  6. {*********************************************************}
  7.  
  8. unit Htmlview;
  9.  
  10. interface
  11.  
  12. uses
  13.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  14.   Forms, Dialogs, ExtCtrls, ReadHTML, HTMLUn1, HTMLSubs, Printers;
  15.  
  16. type
  17.   THotSpotEvent = procedure(Sender: TObject; const SRC: string) of Object;
  18.   THotSpotClickEvent = procedure(Sender: TObject; const SRC: string;
  19.                      var Handled: boolean) of Object;
  20.  
  21.   TThumbScrollBox = class(TScrollBox)
  22.   private
  23.     FCanvas: TCanvas;
  24.     procedure WMVScroll(var Message: TWMVScroll); message WM_VScroll;
  25.     procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_EraseBkgnd;
  26.   public
  27.     constructor Create(AOwner: TComponent); override;
  28.     destructor Destroy; override;
  29.     end;
  30.  
  31.   THTMLViewer = class(TWinControl)
  32.   private
  33.     { Private declarations }
  34.     DontDraw: boolean;
  35.     FTitle: PString;
  36.     FURL: PString;
  37.     FBase: PString;
  38.     FCurrentFile: PString;
  39.     FSectionList: TSectionList;
  40.     FNameList: TStringList;
  41.     FOnHotSpotCovered: THotSpotEvent;
  42.     FOnHotSpotClick: THotSpotClickEvent;
  43.     FOnBitmapRequest: TGetBitmapEvent;
  44.     FOnHistoryChange: TNotifyEvent;
  45.     FHistory: TStrings;
  46.     FHistoryIndex: integer;
  47.     FHistoryMaxCount: integer;
  48.     FFontName: PString;
  49.     FFontColor: TColor;
  50.     FHotSpotColor: TColor;
  51.     FBackGround: TColor;
  52.     FFontSize: integer;
  53.     procedure ScrollResize(Sender: TObject);
  54.     procedure SetViewImages(Value: boolean);
  55.     function GetViewImages: boolean;
  56.     procedure SetColor(Value: TColor);
  57.     function GetBase: string;
  58.     function GetFURL: string;
  59.     function GetTitle: string;
  60.     function GetCurrentFile: string;
  61.     procedure SetBorderStyle(Value: TBorderStyle);
  62.     function GetBorderStyle: TBorderStyle;
  63.     function GetPosition: LongInt;
  64.     procedure SetPosition(Value: LongInt);
  65.     function GetScrollPos: integer;
  66.     procedure SetScrollPos(Value: integer);
  67.     function GetScrollBarRange: integer;
  68.     procedure SetHistoryIndex(Value: integer);
  69.     function GetFontName: TFontName;
  70.     procedure SetFontName(Value: TFontName);
  71.     procedure SetFontSize(Value: integer);
  72.     procedure SetFontColor(Value: TColor);
  73.     procedure SetHotSpotColor(Value: TColor);
  74.     procedure SetOnBitmapRequest(Handler: TGetBitmapEvent);
  75.     procedure WMGetDlgCode(var Message: TMessage); message WM_GETDLGCODE;
  76.     procedure SetupAndLogic;
  77.     procedure BackgroundChange(Sender: TObject);
  78.  
  79.   protected
  80.     { Protected declarations }
  81.     ScrollBox: TThumbScrollBox;   
  82.     PaintBox: TPaintBox;
  83.     function DoLogic: integer;
  84.     function GetURL(X, Y: integer; var URL: OpenString): boolean;
  85.     procedure KeyDown(var Key: Word; Shift: TShiftState); override;
  86.     function GetPalette: HPALETTE; override;
  87.     procedure HTMLPaint(Sender: TObject); virtual;
  88.     procedure HTMLMouseDown(Sender: TObject; Button: TMouseButton;
  89.       Shift: TShiftState; X, Y: Integer); virtual;
  90.     procedure HTMLMouseMove(Sender: TObject; Shift: TShiftState; X,
  91.       Y: Integer); virtual;
  92.     procedure URLAction; virtual;
  93.     function HotSpotClickHandled: boolean; dynamic;
  94.     procedure BumpHistory(const FileName: string; OldPos: LongInt);
  95.     procedure LoadFile(const FileName: string);
  96.  
  97.   public
  98.     { Public declarations }
  99.     constructor Create(AOwner: TComponent); override;
  100.     destructor Destroy; override;
  101.     function HTMLExpandFilename(const Filename: string): string; virtual;
  102.     procedure LoadFromFile(const FileName: string);
  103.     procedure LoadStrings(Strings: TStrings);
  104.     procedure LoadFromBuffer(Buffer: PChar; BufSize: LongInt);
  105.     procedure Print(FromPage, ToPage: integer);
  106.     function PositionTo(Dest: string): boolean;
  107.     property DocumentTitle: string read GetTitle;
  108.     property URL: string read GetFURL;
  109.     property Base: string read GetBase;
  110.     property Position: LongInt read GetPosition write SetPosition;
  111.     property VScrollBarPosition: integer read GetScrollPos write SetScrollPos;
  112.     property VScrollBarRange: integer read GetScrollBarRange;
  113.     property CurrentFile: string read GetCurrentFile;
  114.     property History: TStrings read FHistory;
  115.     property HistoryIndex: integer read FHistoryIndex write SetHistoryIndex;
  116.   published
  117.     { Published declarations }
  118.     property OnHotSpotCovered: THotSpotEvent read FOnHotSpotCovered
  119.              write FOnHotSpotCovered;
  120.     property OnHotSpotClick: THotSpotClickEvent read FOnHotSpotClick
  121.              write FOnHotSpotClick;
  122.     property OnBitmapRequest: TGetBitmapEvent read FOnBitmapRequest
  123.              write SetOnBitmapRequest;
  124.     property OnHistoryChange: TNotifyEvent read FOnHistoryChange
  125.              write FOnHistoryChange;
  126.     property ViewImages: boolean read GetViewImages write SetViewImages;
  127.     property TabStop;
  128.     property TabOrder;
  129.     property Align;
  130.     property Name;
  131.     property Tag;
  132.     property Height default 150;
  133.     property Width default 150;
  134.     property DefBackground: TColor read FBackground write SetColor default clBtnFace;
  135.     property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle;
  136.     property Visible;
  137.     property HistoryMaxCount: integer read FHistoryMaxCount write FHistoryMaxCount;
  138.     property DefFontName: TFontName read GetFontName write SetFontName;
  139.     property DefFontSize: integer read FFontSize write SetFontSize default 12;
  140.     property DefFontColor: TColor read FFontColor write SetFontColor
  141.              default clBtnText;
  142.     property DefHotSpotColor: TColor read FHotSpotColor write SetHotSpotColor
  143.              default clBlue;
  144.   end;
  145.  
  146. procedure Register;
  147.  
  148. implementation
  149.  
  150.